package com.chenfan.ccp.autoconfigure;

import com.chenfan.ccp.plug.log.trace.TraceLog;
import com.chenfan.ccp.plug.business.service.BusinessLogService;
import com.chenfan.ccp.plug.business.service.BusinessLogServiceImpl;
import com.chenfan.ccp.plug.log.RootLogBackLogAppender;
import com.chenfan.ccp.plug.log.config.LogUrlConfig;
import com.chenfan.ccp.plug.log.error.ErrorLog;
import com.chenfan.ccp.plug.log.info.InfoLog;
import com.chenfan.ccp.plug.log.total.TotalLog;
import com.chenfan.ccp.plug.log.warn.WarnLog;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * 日志的注册类
 */
@Configuration
@ConditionalOnProperty(
        name = {"spring.application.name"},
        matchIfMissing = true
)
public class GlobalLogAutoConfigure extends AbstractAutoConfigure {

    private static final String INTERCEPTOR_PATH = "/*";

    /**
     * log 注入=======start=========
     */

    @Bean
    public TraceLog traceLog() {
        return new TraceLog();
    }

    @Bean
    public WarnLog warnLog() {
        return new WarnLog();
    }

    @Bean
    public TotalLog totalLog() {
        return new TotalLog();
    }


    @Bean
    public ErrorLog errorLog() {
        return new ErrorLog();
    }


    @Bean
    public InfoLog infoLog() {
        return new InfoLog();
    }

    /**
     * log 注入=======end=========
     */


    /*
     *自动log路径
     * */
    @Bean
    public LogUrlConfig logUrlConfig() {
        return new LogUrlConfig();
    }

    /**
     * 业务日志
     * @return
     */
    @Bean
    public BusinessLogService businessLogService() {
        return new BusinessLogServiceImpl();
    }


    /**
     * 统一的日志处理
     *
     * @return
     */
    @Bean
    public RootLogBackLogAppender rootLogBackLogAppender() {
        return new RootLogBackLogAppender();
    }

}
